package cn.com.headfree.entity;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.gta.edu.sdk.mybatis.common.Entity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * @Title  TDataRolePermission.java
 * @Package cn.com.headfree.entity
 * @Description 数据权限信息
 * @author yangwang
 * @date  2020年7月3日 下午3:10:12
 */
public class TDataRolePermission extends Entity implements Serializable {
	private static final Logger LOG = LogManager.getLogger(TDataRolePermission.class);

	/**
	 * @Fields serialVersionUID
	 */
	private static final long serialVersionUID = 1L;

	/*角色id*/
	private String roleCode;
	/*角色名称*/
	private String roleName;
	/*18种信息类型id*/
	private String businessTypeId;
	/*18种信息类型名称*/
	private String businessTypeName;
	/*增加权限（0：无   1：有）*/
	private String addFlag;
	/*删除权限（0：无   1：有）*/
	private String delFlag;
	/*修改权限（0：无   1：有）*/
	private String modifyFlag;
	/*查看权限（0：无   1：有）*/
	private String queryFlag;
	/*创建者id*/
	private String createrId;
	/*创建者姓名*/
	private String createrName;
	/*创建时间*/
	private Date createTime;
	/*创建时间Str*/
	private String createTimeStr;
	/*更新者id*/
	private String updaterId;
	/*更新者姓名*/
	private String updaterName;
	/*更新时间*/
	private Date updateTime;
	/*更新时间*/
	private String updateTimeStr;
	/*是否有效数据(0:有效，1:无效)*/
	private Integer isValid;

	/** 开始时间Str */
	private Date startTime;
	/** 开始时间Str */
	private String startTimeStr;
	/** 结束时间Str */
	private Date endTime;
	/** 结束时间Str */
	private String endTimeStr;

	/* 时间格式化YMDHMS */
	private static ThreadLocal<DateFormat> YMDHMS = new ThreadLocal<DateFormat>() {
		@Override
	    protected DateFormat initialValue(){
	        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	    }
	};
	/* 时间格式化YMD */
	private static ThreadLocal<DateFormat> YMD = new ThreadLocal<DateFormat>() {
		@Override
	    protected DateFormat initialValue(){
	        return new SimpleDateFormat("yyyy-MM-dd");
	    }
	};

	public String getRoleCode() {
		return roleCode;
	}
	public void setRoleCode(String roleCode) {
		this.roleCode = roleCode;
	}
	public String getRoleName() {
		return roleName;
	}
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
	public String getBusinessTypeId() {
		return businessTypeId;
	}
	public void setBusinessTypeId(String businessTypeId) {
		this.businessTypeId = businessTypeId;
	}
	public String getBusinessTypeName() {
		return businessTypeName;
	}
	public void setBusinessTypeName(String businessTypeName) {
		this.businessTypeName = businessTypeName;
	}
	public String getAddFlag() {
		return addFlag;
	}
	public void setAddFlag(String addFlag) {
		this.addFlag = addFlag;
	}
	public String getDelFlag() {
		return delFlag;
	}
	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}
	public String getModifyFlag() {
		return modifyFlag;
	}
	public void setModifyFlag(String modifyFlag) {
		this.modifyFlag = modifyFlag;
	}
	public String getQueryFlag() {
		return queryFlag;
	}
	public void setQueryFlag(String queryFlag) {
		this.queryFlag = queryFlag;
	}
	public String getCreaterId() {
		return createrId;
	}
	public void setCreaterId(String createrId) {
		this.createrId = createrId;
	}
	public String getCreaterName() {
		return createrName;
	}
	public void setCreaterName(String createrName) {
		this.createrName = createrName;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
		if(null != createTime) {
			this.createTimeStr = YMDHMS.get().format(createTime);
		}
	}
	public String getCreateTimeStr() {
		return createTimeStr;
	}
	public void setCreateTimeStr(String createTimeStr) {
		this.createTimeStr = createTimeStr;
		if(StringUtils.isNotBlank(createTimeStr)) {
			try {
				this.createTime = YMDHMS.get().parse(createTimeStr);
			} catch (ParseException e) {
				LOG.error("时间字符串转换为时间异常", e);
			}
		}
	}
	public String getUpdaterId() {
		return updaterId;
	}
	public void setUpdaterId(String updaterId) {
		this.updaterId = updaterId;
	}
	public String getUpdaterName() {
		return updaterName;
	}
	public void setUpdaterName(String updaterName) {
		this.updaterName = updaterName;
	}
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
		if(null != updateTime) {
			this.updateTimeStr = YMDHMS.get().format(updateTime);
		}
	}
	public String getUpdateTimeStr() {
		return updateTimeStr;
	}
	public void setUpdateTimeStr(String updateTimeStr) {
		this.updateTimeStr = updateTimeStr;
		if(StringUtils.isNotBlank(updateTimeStr)) {
			try {
				this.updateTime = YMDHMS.get().parse(updateTimeStr);
			} catch (ParseException e) {
				LOG.error("时间字符串转换为时间异常", e);
			}
		}
	}
	public Integer getIsValid() {
		return isValid;
	}
	public void setIsValid(Integer isValid) {
		this.isValid = isValid;
	}
	public void setIsValid(long isValid) {
		this.isValid = Integer.valueOf(String.valueOf(isValid));
	}
	public Date getStartTime() {
		return startTime;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
		if(null != startTime) {
			this.startTimeStr = YMD.get().format(startTime);
		}
	}
	public String getStartTimeStr() {
		return startTimeStr;
	}
	public void setStartTimeStr(String startTimeStr) {
		this.startTimeStr = startTimeStr;
		if(StringUtils.isNotBlank(startTimeStr)) {
			try {
				this.startTime = YMD.get().parse(startTimeStr);
			} catch (ParseException e) {
				LOG.error("时间字符串转换为时间异常", e);
			}
		}
	}
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
		if(null != endTime) {
			this.endTimeStr = YMD.get().format(endTime);
		}
	}
	public String getEndTimeStr() {
		return endTimeStr;
	}
	public void setEndTimeStr(String endTimeStr) {
		this.endTimeStr = endTimeStr;
		if(StringUtils.isNotBlank(endTimeStr)) {
			try {
				this.endTime = YMD.get().parse(endTimeStr);
			} catch (ParseException e) {
				LOG.error("时间字符串转换为时间异常", e);
			}
		}
	}

}
